package org.ThreadDemo.lock;

public class SyncLockDemo {
    public int callbumber = 0;
    public synchronized void add() {
        callbumber++;
        System.out.println(callbumber)  ;
        add();

    };

    public static void main(String[] args) {

        Object o = new Object();
        new Thread(
                ()->{
                    synchronized (o) {
                        System.out.println(Thread.currentThread().getName()+"外层");
                        synchronized (o) {
                            System.out.println(Thread.currentThread().getName() + "中层");
                            synchronized (o) {
                                System.out.println(Thread.currentThread().getName() + "内层");
                            }

                        }
                    }
                }

        ,"t1").start();

        SyncLockDemo a = new SyncLockDemo();
        a.add();
    }
}
